package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo6FlatMap {
  def main(args: Array[String]): Unit = {


    val conf: SparkConf = new SparkConf()
      .setAppName("make")
      .setMaster("local")


    val sc = new SparkContext(conf)

    /**
      * flatMap算子, 扁平化,  将一样数据转换成多行数据
      *
      */

    val rdd: RDD[String] = sc.parallelize(List("java,spark,hadoop", "java,spark,scala"))


    val words: RDD[String] = rdd.flatMap(line => line.split(","))


    words.foreach(println)


  }

}
